package core.C3P0.queryrunner;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import core.C3P0.datasource.*;

/*
 * c3p0工具类2.0
 * 1.不带参数的sql语句
 * 2.不带参数的sql，和数据库连接.
 * 3.带参数的sql语句
 * 4.带参数的sql，和数据库连接
 * 5.反射机制自动封装成一个arraylist 
 *
 * 
 * */
public class QueryRunnerImple implements QueryRunnerDao
{
	 Connection con;
	 Statement sta;
	
	public QueryRunnerImple() throws SQLException
	{
		/*-------执行数据库连接池-------*/
		this.con = C3P0DataSource.GetConnection();		
		/*-------执行数据库连接池-------*/
	}
	
	
	/*--------------不带参数---------------------*/
	public int Update_Runner_UnParaeter(String sql) throws SQLException
	{
		try 
		{
			sta=con.createStatement();
			sta.executeUpdate(sql);
			C3P0DataSource.ReleaveConnection();
			return 1;
		} 
		catch (SQLException e) 
		{
			System.out.println("错误发生在编译时 : "+e);
			System.out.println("错误发生的sql语句为 : "+sql);
			C3P0DataSource.ReleaveConnection();
			return 0;
		}
	}

	
	public ResultSet Search_Runner_UnParaeter(String sql) throws SQLException 
	{		
		ResultSet rs;
		Statement sta;
		
		sta	 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE ,ResultSet.CONCUR_UPDATABLE);
		return rs = sta.executeQuery(sql);
	}

	
	public ResultSet Search_Runner_UnParaeter_con(String sql, Connection con)throws SQLException 
			{
		return null;
	}

	public int Update_Runner_UnParaeter_con(String sql, Connection con)throws SQLException 
	{
		return 0;
	}
	
	/*--------------不带参数---------------------*/
	
	
	
	
	
	
	
	
	
	public int Update_Runner_Paraeter(String sql, ArrayList<Object> obj)throws SQLException 
	{
		return 0;
	}

	
	
	
	public int Search_Runner_Paraeter(String sql, ArrayList<Object> obj)throws SQLException 
	{
		return 0;
	}

	


	
	

	
	
	
	
}
